package pkg;

public class Demo3 {
	public static void main(String[] args) {
		UseCompute com1 = new UseCompute();
		com1.useCom(new add(), 23, 12);
		com1.useCom(new mul(), 3, 4);
		com1.useCom(new div(), 100, 23);
		com1.useCom(new sub(), 67, 78);
	}
}

class UseCompute {
	public void useCom(Compute com, int one, int two) {
		int res = com.computer(one, two);
		System.out.println("result is :" + res);
	}
}

interface Compute {
	int computer(int n, int m);
}

class add implements Compute {
	@Override
	public int computer(int n, int m) {
		return n+m;
	}
}
class sub implements Compute {
	@Override
	public int computer(int n, int m) {
		return n-m;
	}
}

class mul implements Compute {
	@Override
	public int computer(int n, int m) {
		return n*m;
	}
}

class div implements Compute {
	@Override
	public int computer(int n, int m) {
		return n/m;
	}
}